package com.shh.aiojbackendserver.judge.codesandbox;

import com.shh.aiojbackendserver.judge.codesandbox.model.ExecuteCodeRequest;
import com.shh.aiojbackendserver.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@AllArgsConstructor
public class CodeSandboxProxy implements CodeSandbox {

    /**
     * 隐藏了构造函数 codeSandbox = new CodeSandboxProxy(codeSandbox);
     * 将codeSandbox 赋值给了下面这个
     */
    private final CodeSandbox codeSandbox;

    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱信息" + executeCodeRequest.toString());
        //执行的是CodeSandboxFactory.newInstance(type);
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("代码沙箱响应信息" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
